#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>


//void st(char* s)
//{
//	int a = strlen(s);
//	printf("%d ", a);
//}
//int main()
//{
//	char s[] = "asd";
//	st(s);
//	return 0;
//}


int lengthOfLongestSubstring(char* s)
{
    char* left = s;
    char* right = s;
    int sz = strlen(s);
    int a = 1, count = 1, b = 0;
    if (strlen(s) == 0)
        return 0;
    while (*(right))
    {
        if (b == 0)
        {
            right++;
            b++;
        }
        if (*right != *left)
            a++;
        else
        {
            if (count < a)
                count = a;
            a = 1;
            left = left + 1;
        }
        if (a > 2)
        {
            if (*right == *(right - 1))
            {
                a--;
                left = right;
                if (count < a)
                    count = a;
                a = 1;
            }
        }
        right++;
    }
    if (count < a)
        count = a;
    return count;
}
